Skip to content

Line up the Your visitor groups PDF cards by section and truncate long city names. - #13993

Open
mehidi258 wants to merge 5 commits into
developfrom
bug/13221-visitor-groups-alignment-followup
Open

mehidi258 wants to merge 5 commits into
developfrom
bug/13221-visitor-groups-alignment-followup

Conversation

@mehidi258

@mehidi258 mehidi258 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Related issue(s):

Follow-up to #13893 for the QA feedback.

Relevant technical choices

  • Lays the Your visitor groups cards out a section at a time: each section is a row with one cell per card, and a row stretches every cell to its tallest one. Every section lines up across the cards whatever its content (missing cities, a Partial data badge, a wrapped name). This helps us to resolve the issue flagged in QA more appropriate way.

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🤖 This comment is automatically updated by CI workflows. Each section is managed independently.

📚 Storybook for 5eefa1a:

📦 Build files for 5eefa1a:

🎭 Playwright reports for 5eefa1a:

🖼️ VRT report for 5eefa1a:

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the layout of the 'Your visitor groups' PDF widget to render audience cards section-by-section in a grid, ensuring that sections align horizontally across cards. It introduces several new sub-components (PDFAudienceCardHeader, PDFAudienceCardSection, PDFAudienceCitiesRow, PDFAudienceTopContentRow, and PDFAudienceTileNoData), extracts shared styles, and removes the monolithic PDFYourVisitorGroupsTile component. Additionally, it updates PDFTypography to support a custom hyphenationCallback and adds comprehensive unit tests for the new components. Feedback on the changes suggests using a safer unique key combining the title and index in PDFAudienceTopContentRow to prevent duplicate key warnings when rendering top content pages.

…/dashboard/AudienceTilesWidget/PDFAudienceTopContentRow.tsx

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 3.49 MB

ℹ️ View Unchanged
Filename Size Change
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 46.9 kB 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 7.08 kB 0 B
dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 6.29 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 7.09 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 6.29 kB 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/sign-in-with-google/index.js 18.5 kB 0 B
dist/assets/css/googlesitekit-admin-css-********************.min.css 79.2 kB 0 B
dist/assets/css/googlesitekit-adminbar-css-********************.min.css 12.7 kB 0 B
dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 851 B 0 B
dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 9.09 kB 0 B
dist/assets/js/20-********************.js 1.03 kB 0 B
dist/assets/js/22-********************.js 2.41 kB 0 B
dist/assets/js/212-********************.js 2.26 kB 0 B
dist/assets/js/315-********************.js 3.08 kB 0 B
dist/assets/js/397-********************.js 477 kB 0 B
dist/assets/js/492-********************.js 970 B 0 B
dist/assets/js/603-********************.js 61.5 kB 0 B
dist/assets/js/741-********************.js 3.84 kB 0 B
dist/assets/js/792-********************.js 110 kB 0 B
dist/assets/js/959-********************.js 3 kB 0 B
dist/assets/js/analytics-advanced-tracking-********************.js 428 B 0 B
dist/assets/js/googlesitekit-activation-********************.js 31.2 kB 0 B
dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 70.3 kB 0 B
dist/assets/js/googlesitekit-admin-pointers-tracking-********************.js 6.6 kB 0 B
dist/assets/js/googlesitekit-adminbar-********************.js 38.1 kB 0 B
dist/assets/js/googlesitekit-api-********************.js 9.86 kB 0 B
dist/assets/js/googlesitekit-block-tracking-********************.js 6.82 kB 0 B
dist/assets/js/googlesitekit-components-********************.js 6.92 kB 0 B
dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
dist/assets/js/googlesitekit-data-********************.js 1.83 kB 0 B
dist/assets/js/googlesitekit-datastore-forms-********************.js 8.44 kB 0 B
dist/assets/js/googlesitekit-datastore-location-********************.js 1.6 kB 0 B
dist/assets/js/googlesitekit-datastore-pdf-********************.js 1.22 kB 0 B
dist/assets/js/googlesitekit-datastore-site-********************.js 21.4 kB 0 B
dist/assets/js/googlesitekit-datastore-ui-********************.js 8.6 kB 0 B
dist/assets/js/googlesitekit-datastore-user-********************.js 26.6 kB 0 B
dist/assets/js/googlesitekit-entity-dashboard-********************.js 94.1 kB 0 B
dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.27 kB 0 B
dist/assets/js/googlesitekit-events-provider-content-events-********************.js 3.16 kB 0 B
dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 651 B 0 B
dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.24 kB 0 B
dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.26 kB 0 B
dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.28 kB 0 B
dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.35 kB 0 B
dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 895 B 0 B
dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.3 kB 0 B
dist/assets/js/googlesitekit-feature-discovery-********************.js 18.2 kB 0 B
dist/assets/js/googlesitekit-features-********************.js 87.9 kB 0 B
dist/assets/js/googlesitekit-features-badge-********************.js 835 B 0 B
dist/assets/js/googlesitekit-i18n-********************.js 4.43 kB 0 B
dist/assets/js/googlesitekit-intents-********************.js 9.27 kB 0 B
dist/assets/js/googlesitekit-key-metrics-setup-********************.js 65.3 kB 0 B
dist/assets/js/googlesitekit-main-dashboard-********************.js 227 kB 0 B
dist/assets/js/googlesitekit-metric-selection-********************.js 68 kB 0 B
dist/assets/js/googlesitekit-modules-********************.js 30.3 kB 0 B
dist/assets/js/googlesitekit-modules-ads-********************.js 61 kB 0 B
dist/assets/js/googlesitekit-modules-adsense-********************.js 156 kB 0 B
dist/assets/js/googlesitekit-modules-analytics-4-********************.js 311 kB -1 B (0%)
dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 31.7 kB 0 B
dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 138 kB 0 B
dist/assets/js/googlesitekit-modules-search-console-********************.js 78.9 kB 0 B
dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 40.2 kB 0 B
dist/assets/js/googlesitekit-modules-tagmanager-********************.js 34.3 kB 0 B
dist/assets/js/googlesitekit-notifications-********************.js 95.8 kB 0 B
dist/assets/js/googlesitekit-polyfills-********************.js 227 B 0 B
dist/assets/js/googlesitekit-settings-********************.js 89 kB 0 B
dist/assets/js/googlesitekit-splash-********************.js 73.1 kB 0 B
dist/assets/js/googlesitekit-user-input-********************.js 59.5 kB 0 B
dist/assets/js/googlesitekit-vendor-********************.js 315 kB 0 B
dist/assets/js/googlesitekit-vendor-lazy-pdf-********************.js 25.2 kB +596 B (+2.42%)
dist/assets/js/googlesitekit-widgets-********************.js 186 kB 0 B
dist/assets/js/googlesitekit-wp-dashboard-********************.js 46.6 kB 0 B
dist/assets/js/runtime-********************.js 1.94 kB +1 B (+0.05%)
dist/assets/js/sign-in-with-google-********************.js 1.35 kB 0 B

compressed-size-action

@benbowler benbowler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mehidi258. The section grid fixes the dividers and the card bottoms, but the section titles still drift when one card has less data than another, which is the case QA flagged in item 1. Details inline.

Note for QA: item 2 from the QA feedback (long city names overlapping) was flagged as a potential follow-up ticket, but it is fixed in this PR. When this comes back to QA, please also check long city names, including names with no spaces such as "Vacoas-Phoenix", across three cards.

row: {
flexGrow: 1,
flexDirection: 'row',
alignItems: 'center',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because each section fills a cell stretched to the tallest card's section and then centres its content, a section with less content sits lower in its cell. With one card missing cities or with fewer top content rows, the "Cities with the most visitors" and "Top content by pageviews" titles no longer line up across the cards:

misaligned-section-titles

This is from a PDF rendered from this branch with three cards: full data, no cities and one page, and no data with both Partial data badges. Can we top-align the section content within the cell so the titles line up, while keeping the dividers where they are now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking on this @benbowler, Section content is now top-aligned, so the titles line up. Dividers stay where they were.

cityName: {
maxLines: 1,
textOverflow: 'ellipsis',
paddingRight: 11,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 here, backed by "about 10.4px wide" in the comment, reads as a measured value. If this is the ellipsis width at the title small size, shouldn't it come from a specific value in the PDF design and go through our scaling helper (scalePDFValue / createPDFStyles), or be derived from the type scale, rather than being a hardcoded measurement?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the flag @benbowler , The padding is now one em of the city name's font size, taken from the type scale (PDF_TYPOGRAPHY.title.small.fontSize) rather than a hardcoded size.

Comment on lines +55 to +58
// A long city name truncates to one line with an ellipsis. `@react-pdf`
// wraps text by default, so `maxLines` caps it at one line. It draws the
// ellipsis after the last character that fits, so the padding keeps room
// for the ellipsis, about 10.4px wide at this size, inside the city.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to explain this? It is a long comment for one style block; ideally the naming and a short note carry it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shortened to one line, and the style names carry the rest. this applies for all the similar feedbacks.

Comment on lines +110 to +114
{ /*
* A name with a space keeps wrapping at its spaces:
* `@react-pdf` closes up the spaces on a line it
* breaks between characters.
*/ }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to explain this? This inline JSX comment is hard to follow without the splitIntoCharacters docblock above.

Comment on lines +55 to +57
// The cards are laid out a section at a time: each section is a row with
// one cell per card. A row stretches every cell to its tallest one, so each
// section lines up across the cards whatever its content.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to explain this? This and the comments on columns, cardLayer and card below are long and describe the layout in prose; could the structure explain itself through naming with a single short comment on the grid?

} );
} );

it( 'passes the hyphenation callback to the Text', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should pass the hyphenation callback to the Text' ).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @benbowler, Done, updated all the newly added tests to follow guideline.

import PDFAudienceCardHeader from './PDFAudienceCardHeader';

describe( 'PDFAudienceCardHeader', () => {
it( 'renders the audience name', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders the audience name, shows the Partial data badge only when ..., fills its cell, so its divider lines up ....

}

describe( 'PDFAudienceCitiesRow', () => {
it( 'renders each top city with its name and percentage', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders each top city ..., shows a no data message ..., truncates a long city name ..., lets a city name with no space wrap ..., keeps a city name with a space wrapping ....

}

describe( 'PDFAudienceTopContentRow', () => {
it( 'renders each top content row with its title and pageviews', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders each top content row ..., shows a no data message ..., shows the Partial data badge only when ..., fills its cell and drops the divider ..., links each top content title ..., renders each top content title as plain text ....

expect( json.split( 'Partial data' ).length - 1 ).toBe( 1 );
} );

it( 'renders the four metric rows in order, with the pageviews share label', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test titles should start with "should ..." per docs/context/js/tests.md. Same for lays the cards out a section at a time ... below.

@tofumatt
tofumatt changed the base branch from develop to main October 28, 2026 20:15
@tofumatt
tofumatt changed the base branch from main to develop October 28, 2026 20:15

@tofumatt tofumatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting my merge review on this change in anticipation of it being code-reviewed so we can merge it quickly for the release.

The ACs for this issue are straightforward and the IB is very minimal.

Why is this PR 1,400 additions and 700 lines removed? There are a lot of seemingly unrelated changes here for a follow-up release issue.

Additionally: this PR needs to be branched off main as it's a release issue. When I targeted main the commits-to-be-merged went up to 94 instead of 5.

So I think this entire PR needs to be re-thought for the release, please create a new one that addresses only the QA feedback and is based off main.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file doesn't seem well-localised at all. How do these functions behave in Thai or Chinese? And why introduce this logic at all for the changes requested in the AC of this issue?


describe( 'AudienceTilesWidget PDF', () => {
it( 'renders the heading and two cards for two audiences', () => {
it( 'should render the heading and two cards for two audiences', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is requested of the test spec naming, but making all of these changes really inflates this diff. Please be mindful of these types of changes in the future for release issues.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Partial data badge pushes the Purchasers card out of line

3 participants